package demo5;

import java.util.Comparator;

public class Student implements Comparable<Student> {
    public String name;
    public int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public int compareTo(Student o) {
        /*if(this.age > o.age) {
            return 1;
        } else if(this.age == o.age) {
            return 0;
        }else{

            return -1;
        }*/
        return o.age - this.age;
    }



    public String toString() {
        return "Student[" + this.name + "," + this.age + "]";
    }
}
